# This file is part of the Pardus Economy Planner.
#
# The Pardus Economy Planner is free software: you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
#  The Pardus Economy Planner is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
# along with the Pardus Economy Planner.  If not, see
# <http://www.gnu.org/licenses/>.

import os
import sys
import re

# This file will generate the docs for the Pardus Economy Planner using JSDoc
# Download Natural Docs from http://naturaldocs.org
# You will need to set the environment variable NATURALDOCSDIR or pass it to this script for it to work.

NaturalDocsDir = None

if len(sys.argv) == 1:
    if not "NATURALDOCSDIR" in os.environ:
        print "NATURALDOCSDIR not set. Set it to your NaturalDocs installation directory and run this script again."
        exit(1)

    else:
        NaturalDocsDir = os.environ["NATURALDOCSDIR"]

else:
    NaturalDocsDir = " ".join(sys.argv[1:])

# Run the command
os.chdir(os.path.dirname(sys.argv[0]))

cmd = "perl %s -i ./ -o HTML ./Docs -p ./NaturalDocs" % os.path.join(NaturalDocsDir, "NaturalDocs")
print cmd
os.system(cmd)
os.system("pause")
